package 归并;

public class 希尔排序 {
    public static void shell_sort(int a[]) {
        int n=a.length;
        for (int i=n/2;i>0;i=i/2){
            for (int j=i;j<n;j++){
                for (int k=j;k>=i&&a[k]<a[k-1];k=k-i){
                    int temp=a[k];
                    a[k]=a[k-i];
                    a[k-i]=temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int a[] = new int[]{12, 3, 9, 45, 81, 13, 16, 24, 41};
        shell_sort(a);
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + ",");
        }
    }
}